package com.truth.lock.configure;

import com.truth.lock.configure.redisson.RedissonProperties;
import com.truth.lock.configure.zookeeper.ZookeeperProperties;
import com.truth.lock.enumeration.LockServerType;
import com.truth.lock.enumeration.TruthLockType;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

/**
 * @author truth
 */
@ConfigurationProperties(prefix = "truth.lock")
public class TruthLockProperties {

    /**
     * 过期时间 单位：毫秒
     */
    private Long expire = 30000L;

    /**
     * 获取锁超时时间 单位：毫秒
     */
    private Long acquireTimeout = 3000L;

    /**
     * 获取锁失败时重试时间间隔 单位：毫秒
     */
    private Long retryInterval = 100L;

    /**
     * 获取锁的重试次数
     */
    private Long acquireCount = 4L;

    /**
     * 默认使用的锁执行器类型
     */
    private TruthLockType executor;

    /**
     * 使用分布式锁类型
     */
    private LockServerType lockType;

    /**
     * 分布式锁zookeeper配置
     */
    @NestedConfigurationProperty
    private ZookeeperProperties zookeeper;
    /**
     * Redisson配置
     */
    @NestedConfigurationProperty
    private RedissonProperties redisson;

    /**
     * 锁key前缀,暂时不生效，后续增加功能
     */
    private String lockKeyPrefix = "truthLock";

    public Long getExpire() {
        return expire;
    }

    public void setExpire(Long expire) {
        this.expire = expire;
    }

    public Long getAcquireTimeout() {
        return acquireTimeout;
    }

    public void setAcquireTimeout(Long acquireTimeout) {
        this.acquireTimeout = acquireTimeout;
    }

    public Long getRetryInterval() {
        return retryInterval;
    }

    public void setRetryInterval(Long retryInterval) {
        this.retryInterval = retryInterval;
    }

    public Long getAcquireCount() {
        return acquireCount;
    }

    public void setAcquireCount(Long acquireCount) {
        this.acquireCount = acquireCount;
    }

    public String getLockKeyPrefix() {
        return lockKeyPrefix;
    }

    public void setLockKeyPrefix(String lockKeyPrefix) {
        this.lockKeyPrefix = lockKeyPrefix;
    }

    public ZookeeperProperties getZookeeper() {
        return zookeeper;
    }

    public void setZookeeper(ZookeeperProperties zookeeper) {
        this.zookeeper = zookeeper;
    }

    public RedissonProperties getRedisson() {
        return redisson;
    }

    public void setRedisson(RedissonProperties redisson) {
        this.redisson = redisson;
    }

    public LockServerType getLockType() {
        return lockType;
    }

    public void setLockType(LockServerType lockType) {
        this.lockType = lockType;
    }

    public TruthLockType getExecutor() {
        return executor;
    }

    public void setExecutor(TruthLockType executor) {
        this.executor = executor;
    }
}
